﻿using System.Collections.Generic;
using System.Linq;

namespace Crocodile.CsharpLanguage.Tree
{
    public class CsRunBlock : CsStatement
    {

        public bool Braced;


        public readonly IList<CsStatement> Content =
            new List<CsStatement>();


        public override string[] Text
        {
            get
            {
                if (Braced)
                {
                    var buf = new List<string>();
                    buf.Add("{");
                    buf.AddRange(from inner in Content
                                 from line in inner.Text
                                 select '\t' + line);
                    buf.Add("}");
                    return buf.ToArray();
                }
                else
                {
                    return (from inner in Content
                            from line in inner.Text
                            select line 
                           ).ToArray();
                }
            }
        }
    }
}
